<template>
  <div class="line-echart">
    <base-echart :options="lineOption"></base-echart>
  </div>
</template>

<script lang="ts">
import { computed, defineComponent } from 'vue'
import BaseEchart from '@/base-ui/echart'

export default defineComponent({
  props: {
    xLabels: {
      type: Array,
      required: true
    },
    values: {
      type: Array,
      required: true
    }
  },
  components: {
    BaseEchart
  },
  setup(props) {
    const lineOption = computed(() => {
      return {
        title: {
          text: '产品销量图'
        },
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'cross',
            label: {
              backgroundColor: '#6a7985'
            }
          }
        },
        legend: {},
        toolbox: {
          feature: {
            saveAsImage: {}
          }
        },
        grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true
        },
        xAxis: [
          {
            type: 'category',
            boundaryGap: false,
            data: props.xLabels
          }
        ],
        yAxis: [
          {
            type: 'value'
          }
        ],
        series: [
          {
            name: '分别销量',
            type: 'line',
            stack: '总量',
            areaStyle: {},
            emphasis: {
              focus: 'series'
            },
            data: props.values
          }
        ]
      }
    })
    return {
      lineOption
    }
  }
})
</script>

<style scoped></style>
